/*
#include "SRF08.h"
#include <stdbool.h>
#include "RP6I2CmasterTWI.h"
#include "RP6M256Lib.h"

uint16_t srf08_currentDistance=0;
uint8_t srf08_isInitialized=false;
uint8_t srf08_currentLight=0;
uint8_t srf08_isMeasuring = false;

void SRF08_measure(void)
{
	if(!srf08_isMeasuring)
	{
		if(TWI_operation == I2CTWI_NO_OPERATION)
		{
			I2CTWI_transmit2Bytes(SRF08_ADDRESS, 0, 0x51);
			srf08_isMeasuring = true;
			setStopwatch1(0);
		}
	}
	else if(getStopwatch1() > 70)
	{
		while(I2CTWI_isBusy()){
			mSleep(1);
		}
		I2CTWI_transmitByte(SRF08_ADDRESS, 2);
		I2CTWI_requestDataFromDevice(SRF08_ADDRESS, SRF08_HIGH, 1);
		setStopwatch1(0);
	}
}

uint8_t SRF08_init(void)
{
	uint8_t buf[1];
	buf[0]=0;
	while(I2CTWI_isBusy()){
	}
	I2CTWI_readRegisters(SRF08_ADDRESS,0,buf,1);
	if(buf[0]!=SRF08_FIRMWARE){
		srf08_isInitialized=true;
	}else{
		srf08_isInitialized=false;
	}
	return srf08_isInitialized;
}	

void SRF08_onDataReady( uint8_t dataRequestID )
{
	uint8_t messageBuf[8];
	static uint8_t dist_tmp;
	static uint16_t distance;
	switch(dataRequestID)
	{
		case SRF08_READYCHECK: 
			I2CTWI_getReceivedData(messageBuf,1);
			if(messageBuf[1]==0xFF){
				I2CTWI_transmitByte(SRF08_ADDRESS, 2); 
				I2CTWI_requestDataFromDevice(SRF08_ADDRESS, SRF08_HIGH, 1);
			}else{
				I2CTWI_transmitByte(SRF08_ADDRESS, 0);
				I2CTWI_requestDataFromDevice(SRF08_ADDRESS, SRF08_READYCHECK, 1);
			}
			break;
		case SRF08_HIGH: 
			I2CTWI_getReceivedData(messageBuf, 2);
			dist_tmp = (messageBuf[0]);

			I2CTWI_transmitByte(SRF08_ADDRESS, 3);
			I2CTWI_requestDataFromDevice(SRF08_ADDRESS, SRF08_LOW, 1);
		break;
		case SRF08_LOW:
			I2CTWI_getReceivedData(messageBuf, 2);
			distance = messageBuf[0] + (dist_tmp << 8);
			I2CTWI_transmitByte(SRF08_ADDRESS, 1);
			I2CTWI_requestDataFromDevice(SRF08_ADDRESS, SRF08_LIGHT, 1);
		break;
		case SRF08_LIGHT:
			I2CTWI_getReceivedData(messageBuf, 1);
			srf08_currentLight=messageBuf[0];
			srf08_isMeasuring=false;
			srf08_currentDistance=distance;
		break;
	}
}	


uint8_t *SRF08_getLight(void)
{
	return &srf08_currentLight;
}

uint16_t *SRF08_getDistance(void)
{
	return &srf08_currentDistance;
}

uint8_t SRF08_isInitialized(void)
{
	return srf08_isInitialized;
}
*/